package com.flyxteam.supports.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.flyxteam.commons.base.consts.GlobalConsts;

/**
 * 设置编码
 * <ul>
 * <li>2017-01-01 | ChrisX | + create</li>
 * </ul>
 * @author ChrisX
 */
public class EncodingFilter implements Filter {
	
	public void init(FilterConfig config) throws ServletException {
	}

	public void destroy() {
	}

	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
	    servletRequest.setCharacterEncoding(GlobalConsts.ENCODING);
	    servletResponse.setCharacterEncoding(GlobalConsts.ENCODING);
		filterChain.doFilter(servletRequest, servletResponse);
	}
}